約 3,782,902 件
https://w.atwiki.jp/myscripts/pages/22.html
CopyScriptCode をインポート // MyScripts wiki でスクリプトを公開するときにお使いください #PROCESS_SCRIPT function getTinyURL(long_url) { var url = "http //tinyurl.com/api-create.php?url=" + encodeURIComponent(long_url); var req = new XMLHttpRequest(); req.open("GET", url, false); req.send(null); var tiny_url =req.responseText; return tiny_url; } if (SCRIPT_TITLE === null) { alert("スクリプト処理用です。\nスクリプトに対して\n実行してください。"); TARGET = null; null; } else { var import_url = "myscripts //add?title=" import_url += SCRIPT_ENCTITLE; import_url += " script="; import_url += ENCTEXT; import_url += " target="; import_url += SCRIPT_TARGET; var text = "[["; text += SCRIPT_TITLE; text += " をインポート "; text += getTinyURL(import_url); text += "]]\n#highlight("; text += /^#HTML/.test(TEXT) ? "html" "javascript"; text += "){{\n"; text += TEXT; text += "\n}}"; alert("スクリプトコードを\nコピーしました。"); TARGET = "copy"; text; }
https://w.atwiki.jp/ohden/pages/18.html
ECMAScript: ブラウザ毎に仕様の差異がある『JavaScript』『JScript』を仕様統一しようとしてできたもの。 tools jQuery DOM操作用lib。昔は重宝されたが、今はVanillaJSの方が圧倒的に早いので、敬遠されがち。 特に、jQueryを用いるとVanillaに比べてとても遅くなるのがネック。 nodeJS TypeScript JavaScriptに静的型付けを追加したもの。JavaScriptのままでも書けるのでbabelとか入れとるなら突っ込んだ方が吉。 RequireJS D3.js SVG操作用lib。とても使いにくいが、最も支持されてるlib。version 4、5、6で異なる部分が多い。 なので、webなんかで調べたりする時は、自分の使いたいversion no含めて検索するなど気をつけたい。 Vue.js Lodash/Underscore どちらも読み込むと'_'というobjectを使って、VanillaJSに無い機能を提供してくれるlib。 Lodashは、Underscoreのfork。つまり後発で、機能も多い。が、Underscoreの上位互換という訳ではないので注意が必要。 Lodashの機能がVanillaの標準機能に含まれると、Lodashから同等の機能は削除されるって傾向にあるので、使えるんならVanillaの機能を使った方が良い。 Vite ヴィート。webpackなどのfrontend toolに代わるもの。 Svelte Axios Playwright Tabulator tools codepen HTML、JavaScript、CSSでリアルタイムに結果を確認しながら開発ができるサービス。 機能は少ないが、簡素なものを作るのなら問題無い。 Vue Pen Vue版のcodepenがいつの間にかあった。 codesandbox codepenと似たようなサービス。codepenよりも多機能。 特定のframeworkを用いて作成する際に便利。 file explorerを利用できるのが良い。 stackblitz codesandboxみたいに多機能のWebIDE。 editorがVSCodeになってる。 ~ tips ~ parseIntのおかしな挙動 parseFloatのおかしな挙動 ボタンの存在の有無を制御したい 任意の月の最終日を取得したい 入力可能なキーを制限したい 文字列のECMAScriptコードを実行したい Objectの要素数が知りたい Object思考的な扱い方について JSONとJSONPについて 変数のフォーカスについて CSS定義を追加したい ECMAScript/tips/ ~ tips memo ~ Minify ファイル圧縮。記述量を減らしてファイルサイズを小さくする方法。具体的には・tabやspaceの削除: 複数→1や全く消したりする。・改行の削除: 改行→spaceや改行の削除を行う。・true/falseの削除: true→!0、false→!1・変数名の一文字化: 意味を持たせてる変数名を1文字変数化する事で絶対的な文字の数を減らす。ここからはホントに行われるかは知らんけど、可能性のある変換を...・if文の削除: 論理演算子『&&』『||』を用いたり3項演算子を用いる。 !0 true を表す !1 false を表す !!1、!!0 数値から論理型への変換を行う。つまり『1==true→true』『0==false→true』だけど、『1===true→false』『0===false→false』となるのを少ない記述で回避したい場合に使う。2重否定を行う事で『!!1===true→true』『!!0===false→true』とできる。 x()&&y() xの結果がtrueならyを実行true && y(): yは実行される。false && y(): yは実行されない。これは、論理演算子の短絡評価という特性を用いたもの。 x()||y() xの結果がfalseならyを実行true || y(): yは実行されない。false || y(): yは実行される。これは、論理演算子の短絡評価という特性を用いたもの。 短絡評価 最小評価とも言う。これは論理演算が行われる時、左から順に処理が実行され、最終的な論理演算結果が確定した場合、以降の処理を行わないというもの。例えば、論理積の場合『a() && b() && c()』の時、a、b、c全ての結果がtrueでなければ最終結果がtrueにならない。逆に言うと、1つでもfalseを返せばその時点で最終結果がfalseと確定する。つまり、『aがfalseを返したら、b、cの結果に関係無く最終結果がfalseとなるので、b、cをcallしなくても良いよね?しなくて良い処理ならやらないよ!』と言う仕様。当然、aがtrueを返しても、bがfalseを返せばcは実行されない。論理和にも同じ事が言える。論理和がfalseを返すのは、全ての結果がfalseになった時。逆に言うと、1つでもtrueとなればその時点で最終結果がtrueと確定する。論理積の時と同じように『a() || b() || c()』で考える。aがtrueを返すと、b、cの結果に関係無く最終結果がtrueとなるので、b、cをcallする必要は無い。なので、b、cは実行されない。aがfalseを返してもbがtrueを返すとその時点で最終結果がtrueに確定してしまうので、cは実行されない。ただし、言語によっては、論理積の時に短絡評価を行わないものもある。つまり『a() && b() && c()』とあった時、aがfalseを返しても、b、cの処理を行った結果を律儀に論理演算して最終結果を出してくれるって言語仕様。短絡評価を使う場合は、言語仕様をしっかり把握して記述する必要があるので要注意です。 更新日: 2023年09月11日 (月) 01時08分34秒 http //user1.matsumoto.ne.jp/~goma/js/ -- (s1n) 2009-11-12 15 32 06 Require.js -- (s1n) 2014-10-10 10 31 08 var jsObj = JSON.parse(jsonString); var jsonString = JSON.stringify(jsObj); -- (s1n) 2015-03-10 15 35 00 strict mode 厳しく見てくれるモード。開発中はこのモードにしておく方が良いと思う。ただし、利用できるブラウザは限られる。 -- (s1n) 2015-03-10 18 52 32 Object.seal(obj):objへのプロパティ追加を無視する Object.freeze(obj):objへの変更で例外を発生 -- (s1n) 2015-03-10 20 40 51 https //developers.google.com/web/fundamentals/primers/promises?hl=ja#whats-all-the-fuss-about https //developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Promise/then -- (s1n) 2017-10-20 17 32 39 JEST:Javascript test用framework -- (s1n) 2021-01-20 09 37 02 StimulusReflex -- (s1n) 2021-01-20 15 33 30 Next.js:https //nextjs.org -- (s1n) 2021-04-01 16 05 45 名前 コメント すべてのコメントを見る
https://w.atwiki.jp/rubyperl/pages/24.html
JScript ページ新規作成 ;
https://w.atwiki.jp/pagat/pages/17.html
VBScript HTMLの処理(DOM操作など) TypeNameとShell.Applicationを使い起動済みのIEを探す VBScript + HTA(HTML Application)で Canvas を使う方法 お手軽OCRMODI が必要 Javascript Javascriptだけで分かち書き Closure Compiler List of languages that compile to JS JScriptの配列とVBScriptの配列(SafeArray)を相互変換する方法 WSHでjQueryを使う Javascriptで文字コード変換 UWSC サンプル Google App Script GASでお手軽にbotを作る方法 RMeCabによる自然言語処理 テキストマイニングの基礎 Sandbox Wandbox Go Playground PHP Sandbox JSFiddle Perl6 Javascript library JSter Javascriptライブラリカタログ CodeMirror 高機能エディタ
https://w.atwiki.jp/fns1556/pages/46.html
バッチの注意点 IF文 例)小文字aaaを持つ環境変数var0をDefinedでの確認後に大文字AAAへ置換する場合 SET var0=aaa IF DEFINED var0 ( SET var0=%var0 a=A% ECHO %var0% ) 上記だとIF文のブロック内部からは置換後の値をECHOできない。これは、FOR文等のブロック内部を実行前に一括展開するため。 そのため、var0は正しく置換されても置換後の値をブロック要素内部からは既に置換前で展開されているために使えない。 これは、下記のようにIF文のブロック外にECHOを出すか、遅延環境変数(%の代わりに!で括る)を使うことで表示出来る。 遅延環境変数を使うためには、SETLOCALのENABLEDELAYEDEXPANSIONオプションを使うか、cmd.exe /v onのオプションが必要。 FOR文のブロック要素外に出す場合 SET var0=aaa IF DEFINED var0 ( SET var0=%var0 a=A% ) ECHO %var0% 遅延環境変数を利用する場合(SETLOCAL ENABLEDELAYEDEXPANSIONにて利用) SETLOCAL ENABLEDELAYEDEXPANSION SET var0=aaa IF DEFINED var0 ( SET var0=%var0 a=A% ECHO !var0! ) ENDLOCAL 参考:文字列が数値か、他の文字を含むかの判別 (DOSプロンプト活用相談室LOG) 修正パッチ一括インストール(スクリプト) Microsoft Download Centerにて修正パッチを事前にダウンロードする。 以下のauto_install.vbs(権限自動昇格用)及びauto_install.bat(修正パッチ連続実行用(XPも対応))を修正パッチと同じディレクトリ内に置き、auto_install.vbsを実行する。 auto_install.vbs option explicit Dim wmi,os,value,wsh,sha,sfo Set sfo=CreateObject("Scripting.FileSystemObject") do while WScript.Arguments.Count=0 and WScript.Version =5.7 Check if Vista Set wmi = GetObject("winmgmts " "{impersonationLevel=impersonate}!\\.\root\cimv2") Set os = wmi.ExecQuery ("SELECT * FROM Win32_OperatingSystem") For Each value in os if left(value.Version,3) 6.0 then exit do Exit if not Vista Next Run this script as admin. Set sha=CreateObject("Shell.Application") sha.ShellExecute "wscript.exe",""""+WScript.ScriptFullName+""" vista","","runas" WScript.Quit loop Current directory may be moved to system32, maybe not. Dim strScriptPath strScriptPath = Replace(WScript.ScriptFullName, WScript.ScriptName,"") Set wsh=CreateObject("WScript.Shell") wsh.run """" strScriptPath "auto_install.bat" """" auto_install.bat @ECHO OFF SETLOCAL ECHO Install Hotfix? (y/n) default n SET /p Input= IF %ERRORLEVEL% == 1 (GOTO END) IF /i "%Input%"=="y" (GOTO OS_CHECK) ELSE (GOTO END) rem ***************************************************************** OS_CHECK VER | FIND /c "XP" NUL IF %ERRORLEVEL% == 0 (GOTO INSTALL_XP) VER | FIND /c "6." NUL IF %ERRORLEVEL% == 0 (GOTO INSTALL_VISTA) GOTO END rem ***************************************************************** INSTALL_VISTA ECHO Installing Hotfix (msu)... CD /d %~dp0 FOR %%a IN (*.msu) DO ( ECHO Installing %%a %%a /quiet /norestart ) ECHO Do you want to reboot now? (y/n) default n SET /p Input= IF %ERRORLEVEL% == 1 (GOTO END) IF /i "%Input%"=="y" (GOTO REBOOT_VISTA) GOTO END rem ***************************************************************** INSTALL_XP ECHO Installing Hotfix (exe)... CD /d %~dp0 FOR %%a IN (*.exe) DO ( ECHO Installing %%a %%a /quiet /norestart ) ECHO Do you want to reboot now? (y/n) default n SET /p Input= IF %ERRORLEVEL% == 1 (GOTO END) IF /i "%Input%"=="y" (GOTO REBOOT_XP) GOTO END rem ***************************************************************** REBOOT_VISTA SHUTDOWN /r /t 0 GOTO END rem ***************************************************************** REBOOT_XP SHUTDOWN -r -t 0 GOTO END rem ***************************************************************** END ENDLOCAL EXIT /b %ERRORLEVEL%
https://w.atwiki.jp/shells/pages/39.html
JavaScript 読み方 : ジャバスクリプト 別名 : JS Sun Microsystems社とNetscape Communications社が開発した、Webブラウザなどでの利用に適したスクリプト言語 ( 簡易プログラミング言語 )。 Sun社のJava言語に似た記法を用いることが名称の由来だが、直接の互換性は無い。 従来は印刷物のような静的な表現しかできなかったWebページに、動きや対話性を付加することを目的に開発され、主要なWebブラウザのほとんどに搭載されている。 ブラウザ以外のソフトウェアにも簡易な制御プログラムの記述用言語として移植されており、 Microsoft社のWindowsやWebサーバソフト「IIS」、Macromedia社の「Flash」などに、JavaScriptあるいは類似の言語の処理系が内蔵されている。 各社の実装に微妙な違いがあり、ブラウザによって使えない機能があったり同じプログラムでも挙動が異なったりする問題があったため、 ヨーロッパの標準化団体ECMAがソフトウェアメーカーに呼びかけて、通称「ECMAScript」と呼ばれる標準を発行した。 現在では、ECMAScript準拠の処理系をJavaScriptと呼び、 独自の拡張を施したJavaScriptには独自の名称を付ける(Microsoft社は「JScript」、Macromedia社は「ActionScript」)習慣が定着しつつある。 IT用語辞典 戻る
https://w.atwiki.jp/progtips/pages/39.html
後方不一致 (?!token) も使える 後方不一致 (?!token) も使える ソース WSCript.Echo("hoge".match(/hog(?!e)/)); WSCript.Echo("hoge".match(/hog/)); 表示 null hog
https://w.atwiki.jp/piyo12/pages/20.html
デブがデブをデブという -- ぴよ (2010-09-15 08 27 19) swfobjがVBAで触れない。。。。 -- ぴよ (2010-10-08 22 16 21) 名前 コメント memo 1 5 2 2 3 7 4 ? 5 6 6 3,4 7,3,2 9,5,4 a,1,1 q,4,5 b,?,? c,?,4 d,?,9 Private Sub bGET_TAN_Click() 情報メニューを起動する(クリックする) Dim n As Integer ループのカウンター Dim nLinkNo As Integer 見つけたメニューの番号 nLinkNo = -1 エラーの-1で初期化する For n = 0 To Me.WebBrowser2.Document.Links.Length - 1 リンクオブジェクトから探る タイトルが情報メニューのリンクを探す If Me.WebBrowser2.Document.Links(n).Title = "情報メニュー" Then nLinkNo = n 見つけた番号をセットする。 Exit For 見つけたのでループを抜ける。 End If Next n エラーの判断 If nLinkNo = -1 Then -1のまま、見つからなかったら、エラーにする。 MsgBox "情報メニューが見つかりません、システム管理者に連絡してください" Exit Sub 関数を抜ける End If 見つけたリンクを押す .Click Me.WebBrowser2.Document.Links(nLinkNo).Click 単純に.Clickメソッドを使う ↑次は、ここで起動した 情報メニューを捕まえないとなぁ。。。 Dim objOYA_TAG As Object 親のオブジェクトを入れる Set objOYA_TAG = tagSELECT.Item("g").parentElement While objOYA_TAG.tagname "FORM" タグの名前がFORMになるまで(FORM以外の間まわる) Set objOYA_TAG = objOYA_TAG.parentElement さらに、一つ上の親タグを代入 Wend objOYA_TAG.Submit 上へ行き、見つけたフォームを.Submit 送信処理 http //www.ken3.org/cgi-bin/group/vba_ie.asp フォーム(0番目)を .Submit(送信・投稿) する objIE.Document.Forms(0).Submit 送信処理 Option Explicit Dim wait_time As Integer Dim newpage As Integer Dim banne_html As String Sub test2() Dim objie Dim objshell Set objshell = CreateObject("Shell.Application") Set objie = CreateObject("InternetExplorer.Application") objie.Visible = True IEウィンドウを表示 objie.Navigate2 "http //profile.ameba.jp/katharine1209/" 一度アメログのMypage-Topに入る objie.Quit ここで閉じるのはCreateObjectで作成したウィンドウ Set objie = Nothing Set objie = objshell.Windows.Item(objshell.Windows.Count - 1) wait_time = 10 wait objie.Navigate2 "http //peta.ameba.jp/p/addPeta.do?targetAmebaId=katharine1209" Firstペタランクへ移動 MsgBox "test", vbOKOnly End Sub Sub test1() Dim objie Dim objshell Shell.Applicationオブジェクトの作成 Set objshell = CreateObject("Shell.Application") Set objie = CreateObject("InternetExplorer.Application") objie.Visible = True IEウィンドウを表示 objie.Navigate2 "http //www.ameba.jp/" 一度アメログのMypage-Topに入る objie.Quit ここで閉じるのはCreateObjectで作成したウィンドウ Set objie = Nothing Set objie = objshell.Windows.Item(objshell.Windows.Count - 1) wait_time = 10 wait objie.Navigate2 "http //profile.ameba.jp/katharine1209/" Firstペタランクへ移動 wait_time = 10 wait objie.Navigate2 "http //peta.ameba.jp/p/addPeta.do?targetAmebaId=katharine1209" wait_time = 10 wait objie.Navigate2 "http //peta.ameba.jp/p/addPetaComplete.do?targetAmebaId=katharine1209" memo script type="text/javascript" var so = new SWFObject("http //stat.ameba.jp/peta/user/swf/1/peta_button1.swf", "peta_button", "100%", "250", "8", "#ffffff"); so.addParam("menu", "false"); so.addParam("allowScriptAccess","always"); so.addVariable("link", "/p/addPetaComplete.do"); so.addVariable("petaId", "812b65fec6c47f291cb7f51619c70f20"); so.addVariable("targetAmebaId", "banban-bike"); so.write("flashContent"); /script End Sub Sub peta_peta() IE_Obj UF1.PB1.Value = 0 If (Range("D5").Value 1 Or Range("D5").Value 50) Then MsgBox "D5に1~50の数字を入れてください", vbOKOnly Exit Sub End If If (Range("D6").Value 1 Or Range("D6").Value 50) Then MsgBox "D6に1~50の数字を入れてください", vbOKOnly Exit Sub End If If (Range("D5").Value Range("D6").Value) Then MsgBox "D5セルはD6より小さい値(1-50)を入れてください", vbOKOnly Exit Sub End If UF1.LB2.Caption = "0/" Range("D6").Value UF1.TB1.Text = UF1.TB1.Text "IE起動" (Chr(13) + Chr(10)) Dim objie Dim objshell Shell.Applicationオブジェクトの作成 Set objshell = CreateObject("Shell.Application") IEオブジェクトの作成(ダミー) Set objie = CreateObject("InternetExplorer.Application") objie.Visible = True IEウィンドウを表示 objie.Navigate2 "http //www.ameba.jp/" 一度アメログのMypage-Topに入る objie.Quit ここで閉じるのはCreateObjectで作成したウィンドウ Set objie = Nothing いったんオブジェクトをクリア Shell.ApplicationオブジェクトのWindowオブジェクトからIEオブジェクトを取り出す 作成されているポイントは、Windowsコレクションの最後の要素 Set objie = objshell.Windows.Item(objshell.Windows.Count - 1) wait_time = 20 wait ---- login script ---- objIE.Document.srvLoginForm.amebaId.Value = "xxx" objIE.Document.srvLoginForm.Password.Value = "xxx" objIE.Document.styLoginForm.Submit.Click Time Out Dim time60 As Date time60 = DateAdd("S", 60, Now()) Do While objie.Busy = True ビジー中待ち DoEvents If time60 Now() Then 修正必要 MsgBox "タイムアウト", vbOKOnly Exit Sub End If Loop UF1.TB1.Text = UF1.TB1.Text "Firstペタページへ" (Chr(13) + Chr(10)) objie.Navigate2 "http //peta.ameba.jp/p/showPeta.do" Firstペタランクへ移動 wait_time = 20 wait next-page For newpage = Range("D5").Value To Range("D6").Value Step 1 If (newpage 1) Then UF1.TB1.Text = UF1.TB1.Text newpage "ペタページへ" (Chr(13) + Chr(10)) objie.Navigate2 "http //peta.ameba.jp/p/showPeta.do?pageNo=" newpage " allCount=1000" End If --- 20秒待ち wait_time = 20 wait UF1.LB2.Caption = newpage "/" (Range("D6").Value - Range("D5").Value - 1) UF1.PB1.Value = newpage / (Range("D6").Value - Range("D5").Value + 1) * 100 HTMLソース取得 UF1.TB1.Text = UF1.TB1.Text "ソース取得" (Chr(13) + Chr(10)) Dim strHTML As String On Error GoTo error_skip Range("D" (newpage - 1) * 20 + 10).Select Dim i As Integer Dim z As Integer Dim sLink As String Dim sALL As String Dim b As Integer Dim c As String Dim Mystr As String z = 1 For i = 0 To objie.Document.all.Length - 1 deb MsgBox objIE.Document.Links(i).outerText deb MsgBox objIE.Document.Links(i).href deb MsgBox objIE.Document.Links(i).outerHTML sLink = objIE.Document.Links(i).outerHTML sALL = objie.Document.all(i).innerHTML Range("L10").Value = objIE.Document.All(i).InnerHTML If (InStr(1, sLink, "ブログを見る", 1) 0) Then If (InStr(1, sALL, "時", 1) = 3) Then If (InStr(1, sALL, "分", 1) = 6) Then Range("D" (newpage - 1) * 20 + 10).Cells(z, 2).Value = objie.Document.all(i).innerHTML Range("D" (newpage - 1) * 20 + 10).Cells(z, 0).Value = objie.Document.all(i - 4).innerHTML sLink = objie.Document.all(i - 5).innerHTML b = InStr(1, sLink, "ameba.jp/", 1) c = Mid(sLink, b) b = InStr(1, c, "/", 1) Mystr = Mid(c, b + 1) b = InStr(1, Mystr, "/") c = Mid(Mystr, 1, b - 1) Range("D" (newpage - 1) * 20 + 10).Cells(z, 1).Value = c Range("D" (newpage - 1) * 20 + 10).Cells(z, 3).Value = "http //peta.ameba.jp/p/addPetaComplete.do?targetAmebaId=" c " petaID=" Range("D3").Value End If z = z + 1 End If Next i Next newpage UF1.LB2.Caption = "100%" UF1.PB1.Value = 100 UF1.TB1.Text = UF1.TB1.Text "終了処理" (Chr(13) + Chr(10)) --------------終了処理------------------------------ objie.Quit Set objie = Nothing Set objshell = Nothing If (UF1.OB3.Value = False) Then MsgBox "目的通り終了^^", vbOKOnly End If Exit Sub error_skip2 Set objie = Nothing Set objshell = Nothing Exit Sub error_skip MsgBox "Errorです。" (newpage - 1) * 20 "まで取得できました", vbOKOnly GoTo error_skip2 objie.Quit End Sub Sub peta_click() If (Range("D7").Value 1) Then MsgBox "D7セルに1~1000の数字を記載してください" End If If (Range("D8").Value 1000) Then MsgBox "D8セルに1~1000の数字を記載してください" End If If (Range("D8").Value Range("D7").Value) Then MsgBox "D7セルをD8より小さくしてください" End If UF1.PB1.Value = 0 Dim objie Dim objshell Dim i As Integer Loop変数 On Error GoTo error_peta UF1.TB1.Text = UF1.TB1.Text "IE起動" (Chr(13) + Chr(10)) Shell.Applicationオブジェクトの作成 Set objshell = CreateObject("Shell.Application") IEオブジェクトの作成(ダミー) Set objie = CreateObject("InternetExplorer.Application") objie.Visible = True IEウィンドウを表示 objie.Navigate2 "http //www.ameba.jp/" 一度アメログのMypage-Topに入る objie.Quit ここで閉じるのはCreateObjectで作成したウィンドウ Set objie = Nothing いったんオブジェクトをクリア Range("A10 A1009").Value = "" Set objie = objshell.Windows.Item(objshell.Windows.Count - 1) Dim jch As String Dim ipb As Integer jch = "sato613" Range("F10").Select UF1.TB1.Text = UF1.TB1.Text "ペタ実行開始" (Chr(13) + Chr(10)) For i = Range("D7").Value To Range("D8").Value Step 1 UF1.LB2.Caption = ipb "/" (Range("D8").Value - Range("D7").Value + 1) UF1.PB1.Value = ipb / (Range("D8").Value - Range("D7").Value + 1) * 100 ipb = ipb + 1 If (InStr(1, jch, Range("F10").Cells(i, -1), 1) 0) Then Range("F10").Cells(i, -4).Value = "重複" Else objie.Navigate2 Range("F10").Cells(i, 1).Value jch = jch Range("F10").Cells(i, -1).Value "," wait_time = 10 wait Range("F10").Cells(i, -4).Value = "OK" End If Next i ------------- end message ----------------------- UF1.TB1.Text = UF1.TB1.Text "ペタ終了" MsgBox "目的通り終了" objie.Quit Set objie = Nothing Set objshell = Nothing Exit Sub error_peta Range("F10").Cells(i, -4).Value = "NG" UF1.TB1.Text = "ペタERROR" MsgBox "ERROR" i "までペタできました" objie.Quit Set objie = Nothing Set objshell = Nothing End Sub Sub wait() wait_time = 10 Dim newHour As Integer Dim newMinute As Integer Dim newSecond As Integer Dim waitTime As Integer Dim swait As String newHour = Hour(Now()) newMinute = Minute(Now()) newSecond = Second(Now()) + wait_time swait = newHour " " newMinute " " newSecond Application.wait swait End Sub Sub get_html() ムームードメイン banner_html = " a href=http //px.a8.net/svt/ejp?a8mat=1HW0T7+BJKL0Y+348+1BZYSH\ target=\"_blank" " img border="0" width="88" height="31" alt="" src="http //www27.a8.net/svt/bgt?aid=090513691698 wid=001 eno=01 mid=s00000000404008062000 mc=1" /a img border="0" width="1" height="1" src="http //www17.a8.net/0.gif?a8mat=1HW0T7+BJKL0Y+348+1BZYSH" alt="" ロリポップ a href="http //px.a8.net/svt/ejp?a8mat=1HW0T7+EYTB8Y+348+60H7L" target="_blank" img border="0" width="100" height="60" alt="" src="http //www21.a8.net/svt/bgt?aid=090513691905 wid=001 eno=01 mid=s00000000404001010000 mc=1" /a img border="0" width="1" height="1" src="http //www11.a8.net/0.gif?a8mat=1HW0T7+EYTB8Y+348+60H7L" alt="" a href="http //px.a8.net/svt/ejp?a8mat=1HW0T8+4SNQ7M+348+ICD5D" target="_blank" img border="0" width="125" height="125" alt="" src="http //www21.a8.net/svt/bgt?aid=090513692290 wid=001 eno=01 mid=s00000000404003081000 mc=1" /a img border="0" width="1" height="1" src="http //www13.a8.net/0.gif?a8mat=1HW0T8+4SNQ7M+348+ICD5D" alt="" チカッパ a href="http //px.a8.net/svt/ejp?a8mat=1HW0T7+CF4K36+348+15PUCX" target="_blank" img border="0" width="100" height="60" alt="" src="http //www26.a8.net/svt/bgt?aid=090513691751 wid=001 eno=01 mid=s00000000404007007000 mc=1" /a img border="0" width="1" height="1" src="http //www19.a8.net/0.gif?a8mat=1HW0T7+CF4K36+348+15PUCX" alt="" ヘムテル a href="http //px.a8.net/svt/ejp?a8mat=1HW0T7+F4RNAQ+348+U3175" target="_blank" img border="0" width="234" height="60" alt="" src="http //www22.a8.net/svt/bgt?aid=090513691915 wid=001 eno=01 mid=s00000000404005053000 mc=1" /a img border="0" width="1" height="1" src="http //www18.a8.net/0.gif?a8mat=1HW0T7+F4RNAQ+348+U3175" alt="" ライブドア a href="http //px.a8.net/svt/ejp?a8mat=1HVS5B+8KEK4Y+1RHK+661TT" target="_blank" img border="0" width="120" height="90" alt="" src="http //www22.a8.net/svt/bgt?aid=090502463518 wid=001 eno=01 mid=s00000008228001036000 mc=1" /a img border="0" width="1" height="1" src="http //www11.a8.net/0.gif?a8mat=1HVS5B+8KEK4Y+1RHK+661TT" alt="" A8 http //px.a8.net/svt/ejp?a8mat=1HU5F7+9DKSS2+0K+ZSD6A Get Monney http //dietnavi.com/pc/index.asp?id=1856115 ドル箱 http //dorubako.jp/regist.php?i=10435070 Potora http //px.a8.net/svt/ejp?a8mat=1HU5F7+DJM182+1R5C+6EU6Q げんだま a href="http //px.a8.net/svt/ejp?a8mat=1HU6ZY+78RVQQ+1PH2+669JL" target="_blank" img border="0" width="468" height="60" alt="" src="http //www21.a8.net/svt/bgt?aid=090428398438 wid=001 eno=01 mid=s00000007967001037000 mc=1" /a img border="0" width="1" height="1" src="http //www11.a8.net/0.gif?a8mat=1HU6ZY+78RVQQ+1PH2+669JL" alt="" a href="http //px.a8.net/svt/ejp?a8mat=1HW5J9+F75F9E+1IDS+5YRHD" target="_blank" img border="0" width="468" height="60" alt="" src="http //www27.a8.net/svt/bgt?aid=090519813919 wid=003 eno=01 mid=s00000007048001002000 mc=1" /a img border="0" width="1" height="1" src="http //www17.a8.net/0.gif?a8mat=1HW5J9+F75F9E+1IDS+5YRHD" alt="" a href="http //px.a8.net/svt/ejp?a8mat=1HW0T7+F4ROUA+348+U4YN5" target="_blank" img border="0" width="120" height="90" alt="" src="http //www24.a8.net/svt/bgt?aid=090513691915 wid=003 eno=01 mid=s00000000404005062000 mc=1" /a img border="0" width="1" height="1" src="http //www12.a8.net/0.gif?a8mat=1HW0T7+F4ROUA+348+U4YN5" alt="" a href="http //px.a8.net/svt/ejp?a8mat=1HWDDK+EY7X6Q+YPG+HYV1D" target="_blank" img border="0" width="224" height="33" alt="" src="http //www24.a8.net/svt/bgt?aid=090529976904 wid=003 eno=01 mid=s00000004498003018000 mc=1" /a img border="0" width="1" height="1" src="http //www12.a8.net/0.gif?a8mat=1HWDDK+EY7X6Q+YPG+HYV1D" alt="" End Sub End Sub
https://w.atwiki.jp/naobe/pages/73.html
言語に戻る はじめに Netscape社が制定。IEのJScriptとの互換性に問題があり、ECMAの標準規格ECMA-262(JavaScript1.1がベース)が制定され、この規格がJavaScriptの標準規格となった。 2009年時点では、JavaScript1.5~1.7。JavaScript2.0が現在検証中。 文法 コメント //コメント /* コメント */ 演算子 typeof演算子 オペランドに変数を用い、変数の型を表す文字を返す。"string","number","boolean","object","function","undefined"のどれかを返す。 等値演算子(==)と同値演算子(===) ==は型変換を行って、同じ値か確認する。===は型も含めて同じであるか判定する。 【例】 var a = "1"; var b = 1; if( a == b) { document.write("等値 br "); } else { document.write("等値でない br "); } document.write(" br "); if( a === b) { document.write("同値 br "); } else { document.write("同値でない br "); } document.write(" br "); 正規表現 JavaScript1.2から正規表現に対応。 修飾子 g マッチしたものを全て出力。 i 大文字と小文字を区別しない。 例 script !-- var a = "That pen s price is 100$. this pen s price is 200$"; var regx = /[0-9]+/g; var b = a.match(regx); document.write("検索対象文字列" + a + " br "); document.write("正規表現" + regx + " br "); document.write("マッチした文字:" + b + " br "); //-- /script 条件分岐 if 繰り返し処理 while() {} while(条件) { ステートメント } 条件が真の間、ステートメントを実行する。 do { ステートメント } while(条件); 条件が真の間、ステートメントを実行する。最初のステートメントは無条件で実行する。 for in for(プロパティ in オブジェクト) { } オブジェクトのプロパティ名全てに対して処理する。 【例1】 for(var property in navigator) { document.write(navigator[property]); document.write(" br "); } 関数 機能をモジュール化して、共通化する。資源の節約、バグの低減に有効。 書式 function 関数名(引数) { 処理 [return 式] } 関数リテラル 関数を変数(オブジェクト)に代入して使う。 【例】 var func = function(x,y) { return x * y; } func(10, 20); 変数 関数の外部で定義した変数は関数内で使える(グローバル。C言語と同じ)。 【例】 var aaa = "aaa"; function func(x,y) { return aaa; } window.self 自身のwindowオブジェクト window.opener マルチウィンドウの親 windo.parent フレーム分割の1つ親 with文 共通するオブジェクトの記述を省略するために使う。 書式 with(オブジェクト) { } 例 with(document) { write("aaa"); write("bbb"); } 配列 引数は文字列に変換され連想配列として作成される。 初期化 a = []; 代入 a[0] = 1; a[1] = 2; 削除 delete a[0] a[0]がundefinedになり、a[1]は残る。 先頭の抽出 b = a.shift() aの先頭は削除。 最後の抽出 b = a.pop() aの最後は削除。 指定位置の抽出 b = a.slice(start, [end]) endがなければ最後まで。aは変化しない。bは配列になる。 オブジェクト コンストラクタ関数を作成し、newして使う。メソッドは、クラス固有なのでprototypeプロパティに設定する。 【例】 //長方形 function Rectangle(x, y){ this.x = x; this.y = y; } Rectangle.prototype.area = function(){ return this.x * this.y; } var rect = new Rectangle(10, 20); document.write("x:" + rect.x + " br "); document.write("y:" + rect.y + " br "); document.write("面積:" + rect.area() + " br "); クラスプロパティ コンストラクタ関数のプロパティ。定数を表すために使う。名前空間としてクラスを使い名前衝突を防ぐ。 【例】 Number.MAX_VALUE クラスメソッド コンストラクタ関数の関数。汎用的な関数を表すために使う。名前空間としてクラスを使い名前衝突を防ぐ。 【例】 Date.parse() クラスの継承 プロトタイププロパティを利用して、継承したクラスを作成する。 【例】 // クラスの継承 function PointedRectangle(w, h, x, y) { Rectangle.call(this, w, h); this.x = x; this.y = y; } // メソッドを継承させる PointedRectangle.prototype = new Rectangle(); // プロトタイププロパティを削除 delete PointedRectangle.prototype.width; delete PointedRectangle.prototype.height; // コンストラクタを元に戻す PointedRectangle.prototype.constructor = PointedRectangle; var prect = new PointedRectangle(20, 40, 200, 400); 連想配列 プロパティのアクセス方法には以下の2とおりの方法がある。 obj.property = 値; obj["property"] = 値; 2番目の方法を使うとプロパティ名を変数として与えることができるので、連想配列として使える。 WEBアプリケーション Java Scrriptの記述 script タグの中に本体を記述。 script は、何回でも、どこにでも記述可能。ただし呼び出しの前に本体を記述しなければならない。 header タグの中に記述する場合が多い。 JavaScriptに対応していないブラウザに対処するために以下の書式を使う。 script !-- ・・・ //-- /script イベントハンドラ onclick リンク、ボタンの属性。JavaScriptの関数を指定する。falseを返すと、デフォルト処理をキャンセルする(フォームのときは、送信しない。)。 onload body タグに指定する。ドキュメントや画像などの外部コンテンツが完全に読み込まれたときにこのイベントハンドラが呼び出される。 右クリック禁止 body oncontextmenu="return false"" 外部JavaScriptファイル参照 script type="text/javasctipt" src="XXX.js" /script 組み込みメソッド setTimeout(実行する関数, 遅れ時間(ms)) 【例】 ar timer = false; function foo(){ if(timer == false){ setTimeout(function() { timer = true; foo(); timer=false; }, 2000); return; } alert("hello!"); } foo(); 【例12】 var isTrx = 0; var delayTime = 5000; //2重押下抑止 function check() { if (isTrx == 1) { return false; } isTrx = 1; setTimeout( isTrx = 0; , delayTime); return true; } テクニック [Enter]キーでフォームの内容が送信されるのを防ぐ記述 form action="***" method="***" onsubmit="return false;" オブジェクトモデル window +--document | +-- anchors[] | +-- applets[] | +-- Area | +-- forms[] | | +-- elements[] 要素は、Button,CheckBox,・・・ | | +-- Button | | +-- CheckBox | | +-- FileUpload | | +-- Password | | +-- Hidden | | +-- Radio | | +-- Reset | | +-- Select | | | +-- options[] | | | | | +-- Submit | | +-- Text | | +-- Textarea | +-- images[] | +-- links[] +-- history +-- location +-- frames[] +-- navigator +-- screen windowは、ブラウザウィンドウまたはフレームを表す。 フォーム フォーム全体:forms フォームの各要素:elements 添え字によるアクセス document.forms[1].elements[2] ・・ 2番目のformの3番目の要素(button,password,radiobox,textareaなど ) 名前によるアクセス html form name="f1" /form form name="f2" /form /html 上記例では、document.f2 イベント イベント 発生タイミング イベントハンドラ 対象オブジェクト blur ユーザのフォーカスが離れたとき onBlur テキストフィールド focus フォーカスされたとき onFocus テキストフィールド click クリックしたとき onClick ボタン、ラジオボタン、チェックボックス、サブミットボタン、リンク、リセットボタン change 値が変更されたとき onChange テキストフィールド load WebページがWebブラウザにロードされたとき onLoad bodyタグ unload 別のページに移動したとき onUnLoad bodyタグ 【例 onLoad】 body onLoad="alert( ロードしました )" 【例 onUnLoad】 body onUnLoad="alert( 移動しました )" 動作しない!! 新たにウィンドウを開く window.open(URL, ターゲット, フィーチャ); URL ロードするサイトのURL ターゲット フィーチャ 何も設定しなければ、起動もとのウィンドウと同じ。一つでも設定すれば、設定した項目のみ有効。 項目 説明 height=X ウィンドウの高さ width=X ウィンドウの幅 left=X ウインドウの画面左からの位置 top=X ウインドウの画面トップからの位置 location URL入力用のバーを表示 menubar メニューバーを表示 resizable ウィンドウのサイズを変更可能にする status ウィンドウ下のステータスバーを表示 scrollbars スクロールバーを表示 セキュリティ JavaScriptでできないこと クライアントのファイルに対して読み書きができない。 ネットワーク機能自体をサポートしない(生のTCP/IPを使えない) 別ブラウザを開くのは、ボタンクリックなどのユーザ操作に対してのみ。(無制限なポップアップウィンドウ表示をなくすため) クローズできるのは、自分が開いたウィンドウのみ 小さなウィンドウ(100ピクセル以下)を開くことはできない。 スクリプトをロードしたサーバと異なるサーバからロードしたドキュメントを操作することはできない。(同一出身ポリシー) 作成例 html head meta http-equiv="Content-Type" content="text/html; charset=UTF-8" meta http-equiv="Content-Style-Type" content="text/css" meta http-equiv="Content-Script-Type" content="text/javascript" title JavaScriptテスト /title style type="text/css" !-- h1 {font-size 14pt}; h2 {font-size 12pt} -- /style /head body oncontextmenu="return false" onLoad="alert( ロードしました )" onunload="alert( ページを移動しました )" h1 単純な文字出力 /h1 script type="text/javascript" !-- document.write("Hello Java Script."); //-- /script h1 外部ファイル /h1 script type="text/javascript" src="aaa.js" /script h1 正規表現 /h1 h2 マッチした文字を返す /h2 script !-- var a = "That pen s price is 100$. this pen s price is 200$"; var regx = /[0-9]+/g; var b = a.match(regx); document.write("検索対象文字列" + a + " br "); document.write("正規表現" + regx + " br "); document.write("マッチした文字:" + b + " br "); //-- /script h1 繰り返し処理 /h1 h2 for in /h2 script type="text/javascript" !-- for(i in navigator) { document.write(navigator[i]); document.write(" br "); } //-- /script h1 関数の使用 /h1 script type="text/javascript" !-- function func1(a) { return a*2; } document.write("3*2=" + func1(3) + " br " ); //-- /script h1 with文 /h1 script type="text/javascript" !-- with(document) { write("aaa" + " br "); write("bbb" + " br "); } //-- /script h1 マウス右クリック無効化 /h1 script language="JavaScript" !-- function RightOff(e) { if (document.layers e.which == 3){ //NNの場合 alert("右クリックメニューは機能停止しました!"); return false; }else if (document.all event.button == 2) { //IEの場合 alert("右クリックメニューは機能停止しました!"); return false; } return true; } if(document.all){ //IEの場合 document.onmousedown = RightOff; } if(document.layers){ //NNの場合 window.onmousedown = RightOff; window.captureEvents(Event.MOUSEDOWN); } // -- /script firefoxでは無効。 h1 onLoad /h1 p ページを開いたときに起動。bodyタグに記述。 /p h1 onUnLoad /h1 p 別のページに移動したときに起動。bodyタグに記述。 /p a href="http //localhost/PukiWiki/index.php" ホームに移動 /a h1 onBlur/onFocus /h1 form input type="text" onblur="alert( onblur action. )" value="" input type="text" onfocus="alert( onfocus action. )" value="" /form h1 別ウィンドウを開く /h1 h1 タイマー /h1 script type="text/javascript" !-- var cnt = 0; var ret; function rewritePg() { var p = document.getElementById("p1"); if(p == null) { alert("p1 null."); } if( cnt % 2 == 0 ) { p.innerHTML = "bbb"; /** p.firstChild.data = "bbb" でも良い。 */ } else { p.innerHTML = "aaa"; } cnt++; ret = setTimeout("rewritePg()", 2000); } function stopRewrite() { clearTimeout(ret); } //-- /script p 2秒ごとにパラグラフの文字を変える。 /p p id="p1" aaa /p input type="button" value="開始" onClick="rewritePg()" / br input type="button" value="停止" onClick="stopRewrite()" / br / body /html
https://w.atwiki.jp/ltts/pages/36.html
version6.6にてscript(Lua Scripting)に対応しました この機能によりある程度のオートメーション化に役立つと思われますが現時点でサンプルが少なく(2016/02/21現在11件) 初心者は手が出しにくい状態になっています どなたかわかる方は記述をお願いいたします。 参考ページ イントロダクション API サンプル(BlackJack) (参考アドレス) http //steamcommunity.com/sharedfiles/filedetails/?id=714904631 Introduction 導入 This guide is designed for those with limited experience scripting with LUA. このガイドはLUAスクリプトに限って作成されています。(それ以外の言語では対応していません) It will review the basics of how to format code, 基本的なフォーマットコードの見方は the building blocks for you to base your code on and provide some examples. いろいろな例をもって説明します It is designed to be hands-on, so you should have Tabletop Simulator open and your LUA editor up to follow along. 実践ながらLUAエディターを使ってみましょう Before The First Keystroke はじめに First, I would highly recommend getting Atom if you intend to script in Tabletop Simulator. はじめに、スクリプトをいじるために、「Atom」の知識が必要です It knows what functions can be used and will import/export code into/out of TS. 「TS」のインポート、エクスポートを知るために下のアドレスを確認しましょう。Instructions on installation and setup of Atom[berserk-games.com] ↑「Atom」の説明アドレス Next you should 次に下のアドレスをブックマークしておきましょう。 bookmark the documentation knowledge base[berserk-games.com]. You will be referencing this site often once you start to write your own scripts. スクリプト作っていくうちにこのサイトが役にたつでしょう。 Its where you go to find Tabletop Simulator specific functions and how they work. ここにはTTSでのスクリプトがどのように動いているかわかります。 You will most often use the API and Objects pages, at least in my experience. 特に「API」と「Object」のページはよく使うでしょう。 Setting Up 準備 When you save your scripts in Tabletop, あなたのスクリプトをTTSで保存するとき it will use your most recent save and then load the script into it. 最新のセーブ、スクリプトがはいったものを使うこと So for any script you intend to write, you will need to do the following スクリプトを書き足す時には下の事に注意しましょう。 Set up the table the way you want it. テーブルを立てる Save the table. テーブルをセーブする(上の「Menu」から Load the table. テーブルをロードする For this exercise, take a blank table and spawn two objects (I used a square block and rectangle block) as well as a red checker. たとえば右の画像みたいに赤と青のブロックと 赤い確認用コインがあります。 Remember to save/load then open up the scripting in Atom Atomでセーブする前にセーブ ロードすること、 or go to Host Scripting in Tabletop Simulator to begin. ホストとしてTTSをはじめることを覚えておいてください 1) Global.lua ファイルの編集 Global.lua is the scripting which is a part of the save file. 「Global.lua」はセーブデータのスクリプトの一部です。 It is where we will be working for most of this tutorial. 練習の最初としてここをやります。 On a new save, it always starts with some text saved into the editor. 新しいセーブをテキストエディターで開きましょう。 Just delete it, we will not be using it. いったん閉じましょう。これは今回使いません。 It is also possible to write scripts and attach them to objects instead of Global. スクリプトを書くこともできますし、グローバルデータの代わりにも使えます。 That way if you save and object it will save its LUA right along with it. セーブすると自動的にLUAデータとして保存されていきます。 You can perform most functions using either Global or Item scripts but we will be working in Global. このデータは「Global」データか「Item」データとして使うことができますが、 ここでは「Global」データとして使っていきます。 2) Functions 機能 Functions[berserk-games.com] are what trigger groups of code. 「Functions」はコードの1グループとして機能します。 Some of them are built into the scripting system (ex. onload()) while others can be created by the user.Every function will start with the word function and end with the word end. 右の図でいうピンク文字の「function」から「end」までが1グループとなります。 A common function built into Tabletop Simulator is onload(). This function triggers every time the script is loaded (like if Undo/Redo is pressed). TTSでよく使う「onload()」はゲームの読み込み時に機能します。 So let us get started by using it to activate a function we will create. Functions should start with a lowercase letter, and cannot contain spaces. We ll use exampleFunction. 「Functions」の機能は「小文字で表記」し、「スペースを含めてはいけません」 function onload() exampleFunction() end Now our script, when it loads, will try to run a function named exampleFunction. But we haven t written one yet! So now we will create our own function, right after the onload function has ended. 上のままじゃ特に何もおきません。 function exampleFunction() print( Hello, World. ) end The command of print() is also a function. But instead of triggering a section of code in LUA, it activates programming inside of Tabletop Simulator to produce a desired effect. In this case, printing a message to the host of the game, in chat.The message is called a string, and is always surrounded by quotes to indicate that. A string is a series of characters. (Ex This is a string. or So is this! )When you save and upload your script, it should now print Hello, World. to chat. 【print( 表示させたい文字 )】 :「表示させたい文字」がチャット欄に表示されます。 このメッセージは「string」とよばれます Extra Credit When you create your own function, you can also pass variables along with it for the function to use. Another way to write our starting exercise would be 応用編:下の通りにやってみましょう。 function onload() exampleFunction( Hello, World. ) end function exampleFunction(passedString) print(passedString) end We created a variable to represent the string (passedString) and then printed what was contained in that variable. 「passedString」は? 3) Objects オブジェクト Objects[berserk-games.com] are the physical entities that exist within tabletop. In our example, our objects currently are two blocks and a checker (what a terrible game we are making). Using scripting, we can manipulate objects, move them, add buttons to them or perform other various actions. We re starting our Global.lua over fresh. Erase all text in it. 「オブジェクト」はTTSでは物理的なものになります。 たとえば、さっきつくった赤と青とコインがあるだけの謎のゲーム。 これにスクリプトを使って追加したボタンで動きをあたえてみましょう Global.luaを開いて全てのテキストを一度けしましょう。 GUIDs ガイド To affect and object, first we must identify it in LUA. There are several ways to do this, such as identifying items being picked up or put down by players, finding objects inside of a scripting zone and more. We will be identifying these objects by their GUID. まず「プレイヤーがそのオブジェクト」を「持っている」か「持っていないか」を見極めることが大切です。 そのために「GUID」の機能を使いましょう。 A GUID is a unique identifier which each spawned item in TS will have. Even 2 of the same item will have different GUIDs. To locate an object s GUID, right click on it and go to Scripting. If you click on its GUID there, it will copy it to your clipboard. A GUID is always a string, so remember strings are always in quotes. Lets create some variables with the GUIDs of our objects. REMEMBER Your GUIDs will be different than mine. object1_GUID = 195868 object2_GUID = 333365 checker_GUID = 7dc60d TTS上で作られたオブジェクト毎に上のような「GUID」のコードが設定されている。(見た目が同じものや、コピーしたものでも違うGUIDになる) このGUIDはオブジェクトを右クリックしたとき、上記のように、チャット欄に出てくる (上のGUIDのコードはあなたが実際に試したものとは違う数字になるでしょう) Defining Objects オブジェクトの定義 Then, using onload so this happens when the script is loaded, we will make variables to represent our objects. All of these variable names we ve been making must start with a lower case letter and not contain spaces, but other than that you are fairly free to make up variable names yourself. You want to make it clear what it represents. I will be using object1, object2 and checker to represent my objects. The function we will use to identify will be getObjectFromGUID(string). We place the GUID in the spot for the string. 次に、onloadを使用して、スクリプトがロードされたときに、オブジェクトを表す変数を作成します。 これらの変数名はすべて小文字で始まり、空白を含まないようにしなければなりませんが、 変数名を自分で作ることはかなり自由です。 今回は、何を表しているかを明確にしたいので、オブジェクトを表すためにobject1、object2、checkerを使用します。 識別に使用する関数は「getObjectFromGUID(string)」です。 GUIDを文字列の場所に配置します。 function onload() object1 = getObjectFromGUID(object1_GUID) object2 = getObjectFromGUID(object2_GUID) checker = getObjectFromGUID(checker_GUID) end Manipulating Objects オブジェクトの名前設定 Now we need to manipulate these objects somehow. We will give them a name. In onload(), after we defined our objects, we will use the function of setName(string). Notice that setName, like other object functions, must be tied to an object. Otherwise the script will not understand what object s name we want to change. The string in setName will be what we set the name to. これらのオブジェクトを何らかの形で操作する必要があります。 そのため、これらに名前をつけます。 onload()では、オブジェクトを定義した後、setName(string)の関数を使用します。 setNameは、他のオブジェクト関数と同様に、オブジェクトに結びつけられなければならないことに注意してください。 それ以外の場合、スクリプトはどのオブジェクトの名前を変更したいのか理解しません。 setNameの文字列は、名前を設定する文字列になります。 object1.setName( Object1 ) object2.setName( Object2 ) checker.setName( That Stupid Checker ) Extra Credit You may be curious as to why we didn t put the object GUIDs directly into getObject (EX object1 = getObjectFromGUID( 195868 ) ). We could have, it would work. This example was to show you that, sometimes, it is more convenient to set a variable early on so you can reference it later. That way, if that variable needs to change (new GUID) you don t have to try to track it down to fix it throughout your code. If you wanted to, for the checker, there is no reason you couldn t write it like 追記:なぜオブジェクトGUIDを直接getObject(EX:object1 = getObjectFromGUID( 195868 ))に入れなかったのか 疑問をもたなかったでしょうか? そのままでもうまくいくでしょう。 この例では、後で参照できるように、変数を早期に設定する方が便利な場合があることを示しています。 そうすれば、その変数を変更する必要がある場合(新しいGUID)、 コード全体で修正するためにそれを追跡する必要はありません。 あなたが途中のチェック用に使うのでなければとめませんが・・・ function onload() getObjectFromGUID( 7dc60d ).setName( That Stupid Checker ) end The reason I do not encourage that for learners is partially an aesthetic choice, and partially for code clarity. You want it to be easy for someone else to understand your code, and once you start doing things more complex than changing the name of an object it can get VERY difficult to see what is going on. It can also make future revisions to your code a chore. 「先に名前の定義を書く」ことで、やりやすくなるでしょう。 4) Buttons ボタン While there are many ways to activate functions, buttons are a convenient way to activate sections of code at the player s choosing. All buttons must be attached to an object, and are created using parameters. The object we want to attach our button to is our checker, and those parameters are found on the Objects page in the Knowledge Base. Many are optional, here they are for reference. 機能を有効にする方法はたくさんありますが、ボタンはプレーヤーがボタンを押したときにスクリプトを起動するわかりやすい機能です。 すべてのボタンはオブジェクトに関連付けする必要があり、パラメータを使用して作成されます。 ボタンを関連付けするオブジェクトはチェッカーであり、これらのパラメータはナレッジベースのObjectsページにあります。 多くはオプションです。ここでは参考にしています。 click_function = String --The name of the function which will activate when this button is pressed. ボタンを押したときに起動します function_owner = Object --Determines where the function that the button activates lives (global or an object s script). ボタンが有効になる機能(グローバルまたはオブジェクトのスクリプト)を決定します。 labels = String --The name on the button. ボタン自身に名前をつけます position = Table --X, Y and Z coordinates for where the button appears, from the center of the object it is attached to. ボタンが表示される場所のX座標、Y座標、Z座標を、オブジェクトが取り付けられているオブジェクトの中心から取得します rotation = Table --Pitch, Roll and Yaw in degrees, relative to the object it is attached to. 投げる勢い、転がりかた、振り方を、添付したオブジェクトを基準にした角度で表します。 width = Number --How wide the button is, relative to the scale of its object. ボタンの広さを設定します height = Number --How tall the button is, relative to the scale of its object. ボタンの高さを設定します font_size = Number --Size of the text on the button, relative to the scale of its object. ボタン上に表示されるフォントのサイズを設定します。 Tables Tables in LUA are collections of entries. You can store most anything inside of a table and reference it later. All tables are indicated by curly brackets {}. You can reference entries in a table by a name or by an index number (what number entry it is, indexes start at 1 in LUA.). We will be creating a table right beneath where we established our GUIDs and then filling it with entries to use with the createButton(table) function. The name we are choosing for our table is button_paramiters LUAのテーブルはエントリの集合です。 ほとんどのものはテーブルの中に格納し、後で参照することができます。 すべてのテーブルは中括弧{}で示されます。 テーブル内のエントリは、名前またはインデックス番号(どの番号エントリか、LUAのインデックスは1から始まります)によって参照できます。 GUIDを作成した場所の直下にテーブルを作成し、createButton(table)関数で使用するエントリを入力します。 テーブル用に選択している名前はbutton_paramitersです。 button_parameters = {} button_parameters.click_function = buttonClicked button_parameters.function_owner = nil button_parameters.label = Press Me button_parameters.position = {0,0.8,0} button_parameters.rotation = {0,0,0} button_parameters.width = 500 button_parameters.height = 500 button_parameters.font_size = 100 Now we have a table with the paramiters listed within it. So lets use the object function to create a button on the checker. Enter this inside of function onload() before its end. 今度は、その中にリストされたパラメータを持つ表があります。 オブジェクト関数を使用してチェッカーにボタンを作成させます。 終了する前にfunction onload()の中でこれを入力してください。 checker.createButton(button_parameters) Check Your Work 動作確認 Save and apply your code. You should now have a button which floats a few inches above your checker. If you don t see it and didn t get an error, try flipping your checker over. It might be upside down so the button is hiding inside the table! If you did flip the checker over, remember to save over your old save with the checker correctly positioned. コードを保存して適用します。 チェッカーの上に数インチ上に浮かぶボタンがあります。 表示されず、エラーが表示されない場合は、チェッカーを裏返しにしてみてください。 それは、ボタンがテーブルの中に隠れているので、逆さまになっているかもしれません! チェッカーを裏返しにした場合は、チェッカーが正しく配置された状態で古いセーブを保存してください。 Add Button Function ボタン追加 Now we need to add the button s function into our code. To test the function out, we ll print ourselves a message. We ll add this user-defined function to the end of our script. 今度はボタンの機能をコードに追加する必要があります。 関数をテストするために、メッセージを表示します。 このユーザー定義関数をスクリプトの最後に追加します。 function buttonClicked() print( Learning is fun. Sort of. ) end After uploading our script, pressing the button should print our message once for each click. スクリプトをアップロードした後、ボタンを押すと、クリックごとにメッセージが1回表示されます。 Click it repeatedly because of course you will. 同じコードを繰り返すので、繰り返しクリックした表記になります EXTRA CREDIT 追記 When you create tables, there are several ways to accomplish it[www.lua.org]. The way used here was to provide visual clarity. However, creating button parameters like this, if you are going to have many buttons, takes up A LOT of space. I prefer to create my tables in such a way that it saves space but doesn t create a run-on line that goes well off the right side of the screen. Using our example, I would have created my parameter table like this テーブルを作成するときに、テーブルを作成するにはいくつかの方法があります[www.lua.org]。 ここで使用される方法は、視覚的な明快さを提供することでした。 しかし、このようなボタンパラメータを作成すると、多くのボタンを使用する場合は、多くのスペース(広さ)が必要になります。 私はスペースを節約するが、画面の右側からうまくいくランオンラインを作成しないような方法でテーブルを作成することを好みます。 私の例を使って、私は次のように私のパラメータテーブルを作成したでしょう: button_parameters = { click_function= buttonClicked , function_owner=nil, label= Press Me , position={0,0.8,0}, rotation={0,0,0}, width=500, height=500, font_size=100 } EXTRA CREDIT This is the perfect point to start playing with different things you can do with objects. Go to the Object page in the Knowledge Database and try stuff. Move the objects, make them switch positions, change their colors, whatever you can think of. これは、オブジェクトで行うことができるさまざまな作業を開始するのに最適なポイントです。 ナレッジデータベースのオブジェクトページに移動して試してみてください。 オブジェクトを動かす、位置を切り替える、色を変える、何でも考えることができます。 EXTRA CREDIT Also, any time you press a button, its click_function triggers with 2 parameters. The first is an object reference, specifically the reference to the object the button is attached to. The second is a color (ex. Blue ) in string format of the color player who pressed the button. また、ボタンを押すたびに、そのclick_functionが2つのパラメータで引用されます。 1つはオブジェクト参照です。具体的には、ボタンがアタッチされているオブジェクトへの参照です。 2番目のボタンは、ボタンを押したカラープレーヤーの文字列形式の色(例: Blue )です。 5) Logic Statements Logic statements[www.lua.org] are generally called if statements . They are used to tell your code what you want it to do in a given situation. When the statement is activated (say, by pressing a button) the logic contained in its statement will only be activated if the condition given is true. They are always formatted as 論理文[www.lua.org]は、一般に「if文」と呼ばれます。 彼らはあなたのコードを与えられた状況で何をしたいのかを伝えるために使われます。 ステートメントがアクティブになると(たとえばボタンを押すことによって)、ステートメントに含まれるロジックは、指定された条件が真である場合にのみアクティブになります。 それらは常に次のようにフォーマットされます。 if CONDITION then --Activates if condition was true end You can also add else to that, so that if the statement is false, something ELSE happens instead. Notice here I added commenting using two minus signs in a row. The engine will ignore anything on a line after --. また、 else を追加することもできます。その結果、文が偽であれば、代わりにELSEが発生します。 ここでは、2つのマイナス記号を連続して使用してコメントを追加しました。 エンジンは〜の後の行の何かを無視します。 if CONDITION then --Activates if condition was true else --Activates if condition was false end What you place in the area I labeled CONDITION in these examples are called relational and conditional operators.[www.tutorialspoint.com] Using them, you can compare many things to eachother. They produce what is called a boolian value (a variable value that is either true or false ). これらの例でCONDITIONというラベルを付けた領域に配置するものは、リレーショナルおよび条件付き演算子と呼ばれます。[www.tutorialspoint.com]これらを使用して、多くのことをお互いに比較できます。 ブーリアン値(「真」または「偽」のいずれかの可変値)を生成します。 Our First Logic Statements We will try a few of these out. Erase the current contents in your buttonClicked() function. Now enter into that function these statements これらのうちのいくつかを試してみましょう。 buttonClicked()関数の現在の内容を消去します。 その関数に次の文を入力します。 if 5 6 then print( 5 is greater than 6 ) end if 6 4 then print( 6 is greater than 5 ) end if 5 == 0 then print( Five is equal to ZERO?! ) else print( No, five isn t equal to zero. ) end When those lines are used and the button pressed, you will see that only the print functions located in the TRUE statement were printed. Also, because 5==0 is a false statement it activated the print function located in the else part of the logic. これらの行が使用され、ボタンが押されると、TRUEステートメントにある印刷機能だけが表示されます。 また、5 == 0は偽の文であるため、ロジックの「else」部分にある印刷機能を有効にしました。 Comparing Variables Once again, erase all of the scripting inside of the buttonClicked() function. We are going to be creating a new variable, then altering it. The new variable will be a bool. Bool values can only be true, false or nil (nil means neither). Bool values are always written in all lower case. First, we will create our variable just beneath our object and checker GUIDs being established. もう一度、buttonClicked()関数内のすべてのスクリプトを消去します。 私たちは新しい変数を作成し、それを変更します。 新しい変数はboolになります。 Boolの値はtrue、false、またはnil(nilはどちらも意味しません)のみです。 ブール値は常にすべての小文字で記述されます。 まず、オブジェクトとチェッカーのGUIDが確立される直前に変数を作成します。 trueOrFalse = true Then, in buttonClicked, we will establish some logic to check if trueOrFalse is, well, true or false. If it is true, we ll print that it was true and switch it over to false. If the button is clicked again, it will print that it was false and switch it to true. 次に、buttonClickedでは、trueOrFalseがtrue、falseまたはfalseであるかどうかを確認するロジックを確立します。 真であれば、それが本当であることを表示し、それを偽に切り替えます。 ボタンを再度クリックすると、falseであることが表示され、trueに切り替えられます。 if trueOrFalse then print( trueOrFalse was true. ) trueOrFalse = false else print( trueOrFalse was false. ) trueOrFalse = true end We could have also written that as if trueOrFalse == true then but that is unnecesary. Remember, the IF statement just needs to be fed True or False. And since trueOrFalse is already one of those, we can skip the operators. 以下のように書くこともできます」trueOrFalseが、その後真==場合は、「それはunnecesaryであるように、その。IF文がちょうどTrueまたはFalseに供給する必要があることを覚えておいてください。trueOrFalseは既にそのうちの一つであるので、私たちは、事業者をスキップすることができます。 6) Loops Loops are sections of code that can run multiple times/continuously when activated only once. These are some of the more complex elements you will use in LUA. They often go hand-in-hand with tables, allowing you to run code on each entry in the table. ループは、1回だけ起動すると複数回/連続して実行できるコードのセクションです。 これらは、LUAで使用するより複雑な要素の一部です。 彼らはしばしばテーブルと手を携えてテーブルの各エントリにコードを実行させます。 Numeric For Loops A numeric for loop[www.lua.org] is one which runs a set number of times. You give it 2 or 3 numbers and a unique variable name (I will use i , which stands for index) and it starts at the first number, then goes until it hits the second number. If a third number is used, it will count by that. So normally it counts up from 1 by 1, but if you put, as a third number, a 2 it would count by 2s. Each number is separated by a comma. Replace the code in your buttonClicked function with this and give it a try. i , the index, will be equal to 1 on the first run, then it will go up by 1, and be equal to 2 and run again, and keep doing that until it hits 10. ループ[www.lua.org]の数値は、設定された回数だけ実行される数値です。 2つまたは3つの数字と一意の変数名(私は i を使用します)は最初の数字から始まり、2番目の数字に当たるまで続きます。 3番目の数字が使用されている場合は、それによってカウントされます。 通常は1から1までカウントアップしますが、3番目の数字として2を入れると2になります。 各番号はコンマで区切られています。 buttonClicked関数のコードをこれに置き換えて試してみてください。 索引「i」は最初の実行では1になり、次に1になり、2に等しくなり、再び実行され、10に達するまでこれを続けます。 for i=1, 10 do print(i) end print( Loop Finished ) What the output is upon pressing the button ボタンを押したときの出力は何ですか? Generic For Loops A generic for loop[www.lua.org] is one which runs through entries in a table. For example, the button_parameter table we created. We would set two variables, one for index and one for value, in the loop and then it would run through each entry in the provided table. For each entry in the table, it would make index equal the name of the variable (Ex position, width, etc) and value equal that values we gave each entry. Add this after your current for loop in buttonClicked. 一般的なforループ[www.lua.org]は、テーブル内のエントリを実行するものです。 たとえば、作成したbutton_parameterテーブルです。 ループ内に2つの変数(インデックス用と1つの値用)を設定し、提供されたテーブルの各エントリを実行します。 テーブル内の各エントリについて、変数の名前(例:位置、幅など)と同じになり、値は各エントリに与えた値と等しくなります。 buttonClickedの現在のforループの後にこれを追加します。 for i, v in pairs(button_parameters) do print(i) end What the output is upon pressing the button ボタンを押したときの出力は何ですか? Break Break[www.lua.org] will end a for loop as soon as it is activated. For instance, if you added to your numeric for loop, just after its print function, the line if i==3 then break end, it would end the loop after it had printed 1, 2, 3. Break [www.lua.org]は、forループがアクティブになるとすぐに終了します。 たとえば、数字のforループに追加した場合、その印刷機能の直後に、i == 3の場合は行末が終了し、1,2,3の場合はループが終了します。 7) Scripting Outside of Global In order to write a script directly into an object, right click that object in game, go to Scripting, and select Lua Editor (if you use Atom, this will open a window in Atom for it). スクリプトをオブジェクトに直接書き込むには、ゲーム内でそのオブジェクトを右クリックし、Scriptingに行き、Lua Editorを選択します(Atomを使用している場合は、Atomのウィンドウが開きます)。 When you write LUA here, it is just like global. Except if you need to reference the object the script is a part of, you simply write self without the quotes, all lower case. So to create a button on itself, you would use self.createButton(table_of_paramiters). ここでLUAを書くと、それはまるでグローバルに似ています。 スクリプトが含まれているオブジェクトを参照する必要がある場合を除いて、引用符なしにすべて小文字の self と書くだけです。 そのため、ボタン自体を作成するには、self.createButton(table_of_paramiters)を使用します。 Closing I hope this introduction to LUA has helped you better understand some of the underlying mechanics of scripting. If not, then I hope you get lost on your way to throttle me. LUAの紹介が、スクリプトの基本的な仕組みの一部を理解するのに役立ちました。 もしそうでなければ、私はあなたが私を抑えるためにあなたの道に迷ってくれることを願っています。 Remember, the Knowledge Base has information on all the functions which are a part of Tabletop Simulator. That, and some basic practice with if/else/then and for loops will let you accomplish most anything you want. Good luck. 知識ベースには、卓上シミュレータの一部であるすべての機能に関する情報があります。 それと、if / else / thenとforループを使ったいくつかの基本的な習慣は、あなたが望むほとんどのものを達成できるようにします。 がんばろう。 Also, if you are on you way to coding, I have started a list of functions to take care of some more complex processes in Lua. You can find it here. また、あなたがコーディングする方法を知っているなら、私はLuaでもっと複雑なプロセスを扱う関数のリストを開始しました。 ここで見つけることができます。